package com.eztalks.demo;

import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQMessage;

public class MQProducer {
	static ActiveMQConnectionFactory activeMQConnectionFactory = null;
	static Connection proConnetiong = null;
	static MessageProducer createProducer = null;
	static {
		try {
			activeMQConnectionFactory = new ActiveMQConnectionFactory("failover:(tcp://192.168.32.212:61616)");
			proConnetiong = activeMQConnectionFactory.createConnection("root", "123456");
			proConnetiong.start();

			Session session = proConnetiong.createSession(false, Session.AUTO_ACKNOWLEDGE);
			createProducer = session.createProducer(session.createQueue("meeting_status_change_queue"));
			createProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) throws Exception {
		try {
			// int type = message.getIntProperty("type");
			// int roomId = message.getIntProperty("roomId");
			// int roomType = message.getIntProperty("roomType");
			// String devId = message.getStringProperty("devId");
			Message message = new ActiveMQMessage();
			message.setIntProperty("roomId", 304073);
			message.setIntProperty("roomType", 3);
			message.setIntProperty("type", 1);
			message.setStringProperty("devId", "SZ1");
			createProducer.send(message);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
